<html>
<head><meta charset="utf-8"><title>Cargo will always have a bug in `Unit` generation · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html">Cargo will always have a bug in `Unit` generation</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="222329160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222329160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222329160">(Jan 11 2021 at 17:28)</a>:</h4>
<p>With <a href="https://github.com/rust-lang/cargo/issues/9063">https://github.com/rust-lang/cargo/issues/9063</a> now I'm gonna go ahead and call it, Cargo always has a bug in <code>Unit</code> generation that we either know or don't know about</p>



<a name="222329250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222329250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222329250">(Jan 11 2021 at 17:29)</a>:</h4>
<p>while somewhat sarcastic I would say that the current <code>Unit</code> really has not lived up to its promises, and it's weirdly always fraught with bugs. I don't really know how to fix this, but if others have ideas for a large-ish overhaul I think it'd be interesting to explore</p>



<a name="222329303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222329303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222329303">(Jan 11 2021 at 17:29)</a>:</h4>
<p>I've been amazed how for over 5 years consistently there's <em>always</em> been bugs with <code>Unit</code>, dropped edges, stack overflows, etc.</p>



<a name="222345776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222345776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222345776">(Jan 11 2021 at 19:31)</a>:</h4>
<p>There's a lot of complexity that piles up in the form of build scripts, proc-macros, dev-dependencies, rustdoc, etc.  Constructing the unit graph is the one place where all that complexity gets focused. I'm skeptical that the complexity could be isolated or layered in a way that would be noticeably better than it is now.  </p>
<p>I think it is somewhat fundamental to the high-level nature of Cargo. There needs to be some sort of graph of nodes to track the dependencies, and <code>Unit</code> is probably as good as any other choice. The issue is that Cargo has some really high-level concepts (build scripts, <code>links</code>, proc-macros, etc.) that require wiring a bunch of dependency edges correctly. Something like ninja is much simpler because it requires the user to explicitly state all those dependencies. To me it seems like that is just the nature of having a lot of high-level concepts with a bunch of implicit rules. The apparent complexity is deceptively hidden. If Cargo just spit out a ninja file, I think it would still suffer the same issues.</p>



<a name="222346961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222346961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222346961">(Jan 11 2021 at 19:40)</a>:</h4>
<p>Nah I definitely agree with this assessment, and it's what I've often thought as well. We've been able to get away with various tweaks over time because the high-level concepts aren't always super-precisely defined. Additionally I've often thought that we're alleviating all other users from writing buggy ninja-files (if they were to write something more low-level). </p>
<p>Despite all that though I'm genuinely impressed how buggy <code>Unit</code>-related construction has been over time. We always seem to be in a weird valley of at least one bug or two. The saving grace is that it at least doesn't seem to come up all that often for projects!</p>
<p>I agree there's probably not a great alternative though, but I'd still love to find one anyway heh</p>



<a name="222472309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Cargo%20will%20always%20have%20a%20bug%20in%20%60Unit%60%20generation/near/222472309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> John Ericson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Cargo.20will.20always.20have.20a.20bug.20in.20.60Unit.60.20generation.html#222472309">(Jan 12 2021 at 18:15)</a>:</h4>
<p>I was always skeptical that proc macros wasn't their own dependency type. Especially with cross and things, it's not just a different type of node, but also a different type of edge.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>